import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';

Widget reFreshHeader() {
  return Builder(builder: (context) {
    return const ClassicHeader(
      textStyle: TextStyle(color: Colors.black),
      refreshingText: "刷新中",
      completeText: "刷新完成",
      failedText: "刷新失败",
      releaseText: "释放刷新",
      idleText: "下拉刷新",
    );
  });
}

Widget loadFooter() {
  return Builder(builder: (context) {
    return CustomFooter(
      builder: (BuildContext context, LoadStatus? mode) {
        Widget body;
        if (mode == LoadStatus.idle) {
          body = const Text("上拉加载");
        } else if (mode == LoadStatus.loading) {
          body = const CupertinoActivityIndicator();
        } else if (mode == LoadStatus.failed) {
          body = const Text("加载失败");
        } else if (mode == LoadStatus.canLoading) {
          body = const Text("释放加载更多");
        } else {
          body = const Text("没有更多数据了");
        }
        return DefaultTextStyle(
          style: const TextStyle(color: Colors.black),
          child: SizedBox(
            height: 55.0,
            child: Center(child: body),
          ),
        );
      },
    );
  });
}
